package com.wy.dao;

import com.wy.model.Room;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @描述
 * @创建人 wangyue
 * @创建时间2019/12/216:29
 */
@Repository
public interface RoomDao extends JpaRepository<Room,String>,JpaSpecificationExecutor<Room> {

    List<Room> findByCode(String code);

    List<Room> findByCodeLike(String code);

    Page<Room> findByCodeLike(String code,Pageable pageable);

    Page<Room> findByCodeLikeAndStateOrderByCodeDesc(String code,String state,Pageable pageable);

    @Query("select u from Room u where u.code like %?1%")
    List<Room> getlist(String code);

    @Query(value="select * from t_room u where u.code like %?1%",nativeQuery = true)
    List<Room> getlist2(String code);
}
